Skip to content

Add transcript localization support#16

Draft
davelab6 wants to merge 3 commits into
mainfrom
davelab6-all-langs
Draft

Add transcript localization support#16
davelab6 wants to merge 3 commits into
mainfrom
davelab6-all-langs

Conversation

@davelab6

Copy link
Copy Markdown
Contributor

I got a large set of VTT titles for the latest video

find . -maxdepth 1 -type f -name "*.vtt" \
| while read FILE_PATH; do
    # 1. Extract the base video ID and a dash (-)
    BASE_NAME=$(basename "$FILE_PATH" .vtt)

    # 2. Check if a language-specific version of that video exists
    #    The grep pattern looks for the BASE_NAME followed by a period and
    #    at least two non-period characters (the language code) before .vtt
    if ls "$BASE_NAME".??*.vtt 2>/dev/null; then
        echo "Deleting: $FILE_PATH (Found language-specific duplicate)"
        git rm "$FILE_PATH"
    fi
done
find . -maxdepth 1 -type f -name "*.vtt" \
| while read FILE_PATH; do
    # 1. Extract the base name (everything before the final .vtt)
    BASE_NAME=$(basename "$FILE_PATH" .vtt)

    # 2. Check if the file is a GENERIC VTT (i.e., its name does NOT contain a language code)
    #    This uses parameter expansion to check if the basename is the same as the part
    #    before a language code. If they differ, it is already language-specific.
    if [[ "$BASE_NAME" != *".??."* && "$BASE_NAME" != *".??-??."* ]]; then
        # Check if a language-specific version of this video ID ALREADY EXISTS
        # The glob pattern checks for BASE_NAME followed by a language code (.?? or .??-??)
        if ! ls "$BASE_NAME".??*.vtt 2>/dev/null; then
            NEW_FILE_PATH="${BASE_NAME}.en-GB.vtt"
            echo "Renaming: $FILE_PATH  ->  $NEW_FILE_PATH"
            git mv "$FILE_PATH" "$NEW_FILE_PATH"
        fi
    fi
done
@davelab6 davelab6 requested a review from Copilot October 26, 2025 22:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants